package library.and.xps.com.step.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.jude.utils.JUtils;
import com.orhanobut.logger.Logger;
import com.zhy.autolayout.utils.AutoUtils;

import java.util.ArrayList;
import java.util.List;

import library.and.xps.com.step.R;
import library.and.xps.com.step.m.model.TeamManager;

public class DepartmentListAdapter extends BaseAdapter {
    Context mContext;
    List<TeamManager.ListBean> data = new ArrayList<>();

    public DepartmentListAdapter(Context con) {
        mContext = con;
    }

    public void setData(List<TeamManager.ListBean> data) {
        this.data = data;
        notifyDataSetChanged();
    }

    public List<TeamManager.ListBean> getData(){
        return data;
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    ViewHolder vh;

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        if (convertView == null) {
            vh = new ViewHolder();
            convertView = (((LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.teammanager_teamlist_item, null));
            vh.tv_name = (TextView) convertView.findViewById(R.id.tv_dname_teammanager_item);
            convertView.setTag(vh);
            AutoUtils.auto(convertView);
        } else {
            vh = (ViewHolder) convertView.getTag();
        }

        vh.tv_name.setText(data.get(position).getDname());

        return convertView;
    }

    private class ViewHolder {
        public ViewHolder() {
        }

        TextView tv_name;
    }

}
